/**
 * 
 */
package com.base.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

import com.base.model.MessageSend;

/**
 * @author ricky
 * 
 */
public class ObjectClientHandler extends ChannelInboundHandlerAdapter {

	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg)
			throws Exception {
		if(msg instanceof String){
			System.out.println(msg);
		}else{
			if(msg instanceof MessageSend){
				MessageSend messageSend = (MessageSend)msg;
				System.out.println(messageSend.getMessage()+" from user:"+messageSend.getFromUserName());
			}
		}
		
		super.channelRead(ctx, msg);
	}

	@Override
	public void channelActive(ChannelHandlerContext ctx) throws Exception {
		System.out.println("client connect");
		super.channelActive(ctx);
	}
}
